#*************************************************************************
#** Copyright (C) 2013 Jan Pedersen <jp@jp-embedded.com>
#** 
#** This program is free software: you can redistribute it and/or modify
#** it under the terms of the GNU General Public License as published by
#** the Free Software Foundation, either version 3 of the License, or
#** (at your option) any later version.
#** 
#** This program is distributed in the hope that it will be useful,
#** but WITHOUT ANY WARRANTY; without even the implied warranty of
#** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#** GNU General Public License for more details.
#** 
#** You should have received a copy of the GNU General Public License
#** along with this program.  If not, see <http://www.gnu.org/licenses/>.
#*************************************************************************

CPPFLAGS := -Wall -O2 -MD -MP
CPPFLAGS += -isystem gtest-1.7.0/include -pthread

test.objs := test.o

all: test

clean: gtest.clean
	rm -f test
	rm -f $(patsubst %.txml,%.h,$(wildcard *.txml))
	rm -f $(patsubst %.txml,%.scxml,$(wildcard *.txml))
	rm -f $(test.objs) $(test.objs:.o=.d)

$(test.objs): libgtest.a

test: $(test.objs)
	$(CXX) -o $@ $^ libgtest.a -lpthread

-include $(test.objs:.o=.d)

include scxml.mk
include gtest.mk

%.scxml: %.txml
	xsltproc cpp.xsl $^ > $@

# Initial depedency files must be generated to be able to auto generate .h from .scxml
%.d: %.cpp
	$(CXX) -MM -MG $^ > $@

